/**
 * The AndCreationTool allows the user to create a new And
 * by clicking at the place where there should be the top/left corner.
 * The And currently have a fixed size of 20 by 40 pixels.
 * 
 * @author  Giuseppe Mendola (giuseppe.mendola@usi.ch);Gregory Banfi (gregory.banfi@usi.ch);
 */

package ch.usi.inf.pf2.gui;

import java.awt.event.MouseEvent;

import ch.usi.inf.pf2.Value;
import ch.usi.inf.pf2.puts.Input;

public final class InputCreationTool extends Tool {

	public InputCreationTool(final Model model) {
		super(model, "Create an Input ", "inputCone.gif");
	}

	/**
	 * This method responds to the mouseClicked event on the inputCreationTool.
	 * When the user clicks it prints a message, and creates a new input object
	 * with a predefined value Unknown at the position of the mouse clicked.
	 * Then the input is added to the drawing, the previous selection is cleared
	 * and the new input is selected.
	 */
	@Override
	public void mouseClicked(final MouseEvent ev) {
		System.out.println("mouseClicked: " + ev);
		final Input input = new Input(Value.UNKNOWN, ev.getX(), ev.getY());
		getDrawing().add(input);
		getSelection().clear();
		getSelection().add(input);
	}
}